package com.itheima.user.controller;

import com.itheima.entity.dto.BlackListDto;
import com.itheima.entity.vo.Result;
import com.itheima.user.service.BlackListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author :wujunjie
 * createTime :2022-12-15 20:22
 * description :
 */
@RestController
@RequestMapping("/userService/blackList")
public class BlackListController {

    @Autowired
    private BlackListService blackListService;

    @PostMapping
    private Result insertBlackList(@RequestBody BlackListDto blackListDto){
        Boolean insert=blackListService.insertBlackList(blackListDto);
        if (insert){
            return Result.success();
        }
        return Result.error();
    }

    @DeleteMapping("{blackId}")
    public Result deleteblackList(@PathVariable String blackId){
        Boolean delete = blackListService.deleteBlackList(blackId);
        if (delete){
            return Result.success();
        }
        return Result.error();
    }


    @GetMapping
    public Result selectPage(@RequestParam(name = "name",required = false) String name,
                             @RequestParam(name="page",defaultValue = "1") Integer page,
                             @RequestParam(name="pageSize",defaultValue = "10") Integer pageSize){

        return Result.success(blackListService.selectPage(name,page,pageSize));

    }


}
